<?php

namespace app\admin\model\westts\goods;

use think\Model;


class Prize extends Model
{

    

    

    // 表名
    protected $name = 'westts_goods_prize';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'open_prize_status_text'
    ];
    

    
    public function getOpenPrizeStatusList()
    {
        return ['wait' => __('待开奖'), 'no' => __('未中奖'), 'first' => __('一等奖'), 'second' => __('二等奖'), 'third' => __('三等奖')];
    }


    public function getOpenPrizeStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['open_prize_status']) ? $data['open_prize_status'] : '');
        $list = $this->getOpenPrizeStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    public function goods()
    {
        return $this->belongsTo('app\admin\model\shopro\goods\Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


}
